package com.luo.bbs.front.webapi.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.luo.bbs.front.webapi.mapper.TagMapper;
import com.example.bbs.front.service.ITagService;
import com.luo.common.exception.BBSServiceException;
import com.luo.common.restful.ResponseCode;
import com.luo.pojo.tag.entity.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author bin.cn
 * @since 2023-01-19
 */
@Service
public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements ITagService {

    @Autowired
    private TagMapper tagMapper;

    @Override
    public List<Tag> listTag() {
        QueryWrapper<Tag> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delete_status",0);
        queryWrapper.orderByAsc("sort");
        return tagMapper.selectList(queryWrapper);
    }

    @Override
    public Tag getTagDetail(Integer id) {
        if (id==null){
            throw new BBSServiceException(ResponseCode.BAD_REQUEST,"参数为空");
        }
        Tag tag = tagMapper.selectById(id);
        return tag;
    }
}
